package com.looookme.shaozhuo.uicompent;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.looookme.shaozhuo.mb_study.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Shaozhuo on 2015/9/7.
 */
public class UiUpperCompent extends Activity {
    private ListView mListView;
    private List<String> mData;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.uiupperlayout);

        initView();
        initEvent();
    }

    private void initEvent() {
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent = new Intent();
                switch (i){
                    case 0:
                        intent.setClass(UiUpperCompent.this, Ui_AutoCompleteTextView.class);
                        break;
                    case 1:
                        intent.setClass(UiUpperCompent.this, Ui_ProgressBar.class);
                        break;
                    case 2:
                        intent.setClass(UiUpperCompent.this, Ui_SeekBar.class);
                        break;
                    case 3:
                        intent.setClass(UiUpperCompent.this, Ui_RatingBar.class);
                        break;
                    case 4:
                        intent.setClass(UiUpperCompent.this, Ui_TabHost.class);
                        break;
                    case 5:
                        intent.setClass(UiUpperCompent.this, Ui_ImageSwitcher.class);
                        break;
                    case 6:
                        intent.setClass(UiUpperCompent.this, Ui_GridView.class);
                }
                startActivity(intent);
            }
        });
    }

    private void initView() {
        mListView = (ListView)findViewById(R.id.uiupper_listView);
        mData = new ArrayList<String>();

        mData.add("Ui_AutoCompleteTextView");
        mData.add("Ui_ProgressBar");
        mData.add("Ui_SeekBar");
        mData.add("Ui_RatingBar");
        mData.add("Ui_TabHost");
        mData.add("Ui_ImageSwitcher");
        mData.add("Ui_GridView");


        mListView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mData));
    }
}
